﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Globalization;
using Public;

namespace WebsiteAdmin.Wilson.News.Handler
{
    /// <summary>
    /// $codebehindclassname$ 的摘要说明
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    public class Delete : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string rtn = "";
            if (Cookie.AdminLoginName != null || Cookie.AdminLoginName != "")
            {
                int pkid = Convert.ToInt32(context.Request["PKID"], CultureInfo.InvariantCulture);
                rtn = DoDelete(pkid);
            }
            context.Response.Write(rtn);
            HttpContext.Current.ApplicationInstance.CompleteRequest();
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }

        private static string DoDelete(int pkid)
        {
            int rtn = Bll.News.Delete(Global.ConnWilson, pkid);
            return ((rtn == 1) ? "{ \"Done\": \"Success\" }" : "{ \"Done\": \"Failed\" }");
        }
    }
}
